<!--
 * @description  :举报记录表 文书
 * @descriptionDetail:举报记录表 文书
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-12 22:21:21
-->
<template>
  <view class="page">
    <doc-component
      ref="docComRef"
      :bizUuid="recordItem.bizUuid"
      docCode="clueReportInfo"
      :docInsUuid="recordItem.uuid || ''"
      :mainInfo="{typeCode:'qbcz',itemCode:'qbjy',}"
      :rules="rules"
      :detailInfo="detailInfo"
      @back="back"
    >
      <template slot="formItems" slot-scope="d">
        <u-form-item
          label="举报时间" prop="reportTime" :right-icon="!d.justView ? 'calendar' : ''"
          :required="!d.justView" :rightIconStyle="rightIconStyle"
        >
          <u-input
            placeholder="系统获取当前时间" :disabled="true" v-model="d.formData.reportTime"
            @click="clickRegDate"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="举报形式" rightIcon="" :required="!d.justView"
          prop="reportType" :rightIconStyle="rightIconStyle"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.REPORT_STYLE"
            :dicCode="d.formData.reportType"
            :border="false"
            type="text"
            :select-open="dicSelectOpen('reportType',$u.dic.DIC_KEYS.REPORT_STYLE)"
            placeholder="请选择"
            :disabled="true"
            v-model="d.formData.reportTypeName"
            @changeInputModelData="(name)=>{$set(d.formData, 'reportTypeName', name)}"
          />
        </u-form-item>
        <u-form-item label="举报人有关情况" :required="!d.justView" prop="reportPersonDesc">
          <!-- d.justView -->
          <u-input
            type="textarea" :disabled="true" v-model="d.formData.reportPersonDesc"
            placeholder="请输入举报人有关情况"
          ></u-input>
        </u-form-item>
        <u-form-item label="举报内容" :required="!d.justView" prop="reportContent">
          <!-- d.justView -->
          <u-input
            type="textarea" :disabled="true" v-model="d.formData.reportContent"
            placeholder="请输入举报内容"
          ></u-input>
        </u-form-item>
        <u-form-item label="接举报人意见" prop="receptionAdvice" :required="!d.justView">
          <u-input
            type="textarea" :disabled="d.justView" v-model="d.formData.receptionAdvice"
            placeholder="请输入接举报人意见"
          ></u-input>
        </u-form-item>
		<u-form-item label="接举报日期" prop="receptionTime" :right-icon="!d.justView ? 'calendar' : ''"  :rightIconStyle="rightIconStyle">
		  <u-input
		    placeholder="接举报日期" :disabled="true" v-model="d.formData.receptionTime"
		    @click="clickReceptionDate"
		  ></u-input>
		</u-form-item>
		
      </template>
    </doc-component>
    <u-picker
      v-model="dateShow" mode="time" :params="pickerParams"
      @confirm="changeDate"
    ></u-picker>
    <!-- 下拉选择用 -->
    <dic-choice
      :keyWord="dicKeyWords" :currentSelect="dicCurrentSelect" v-model="dicShow"
      @confirm="selectDicConfirm"
    ></dic-choice>
	
	<u-calendar mode="date" :max-date="maxDate" v-model="isShowDate" @change="changeReceptionDate('receptionTime',$event)">
	</u-calendar>
	
  </view>
</template>

<script>
import DicChoice from '@/components/dic_choice.vue';
import DicInput from '@/components/dic_input.vue';
import DocComponent from '../../commonPage/docComponent.vue';
import moment from "moment";
import {
	dateUtils,
} from "@/common/util";
export default {
  components: {
    DicChoice,
    DicInput,
    DocComponent,
  },
  data() {
    return {
      user: this.$storage.get(this.$rp.common.USER),
      dicKeyWords: '',
      dicCurrentSelect: '',
      minDate: this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd'),
      pickerParams: {
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: true,
        // 选择时间的时间戳
        timestamp: true,
      },
      dicShow: false,
      dicType: '',
      delt: 1,
      rules: {
        reportTime: [
          {
            required: true,
            message: '请选择举报时间',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
        receptionAdvice: [
          {
            required: true,
            message: '请接举报人意见',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
        reportContent: [
          {
            required: true,
            message: '请输入举报内容',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
        reportPersonDesc: [
          {
            required: true,
            message: '请输入举报人有关情况',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
        reportType: [
          {
            required: true,
            message: '请选择举报形式',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
      },
      rightIconStyle: {
        fontSize: '40rpx',
      },
      dateShow: false,
      recordItem: {},
      detailInfo: {},
	  isShowDate:false,
	  maxDate: '2099-12-31',
	  moment,
    };
  },
  onLoad(opt) {
    if (this.$u.test.isEmpty(opt.delt)) {
      this.delt = 1;
    } else {
      this.delt = opt.delt;
    }
    this.recordItem = this.getRouteParam();
    this.detailInfo = this.recordItem.detailInfo;
    console.log(this.recordItem, this.detailInfo, 'routerparam');
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {},
    changeDate(e) {
      this.$refs.docComRef.setFormDataByKey('reportTime', this.$u.date(e.timestamp, 'yyyy-mm-dd hh:MM:ss'));
    },
    clickRegDate() {
      if (this.$refs.docComRef.justView) return;
      this.dateShow = true;
    },
    selectDicConfirm(e) {
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.REPORT_STYLE) {
        this.$refs.docComRef.setFormDataByKey('reportTypeName', e[0].label);
        this.$refs.docComRef.setFormDataByKey('reportType', e[0].extra.bcbCode);
      }
    },
    showDic(key, cur, type) {
      if (this.dicShow || this.$refs.docComRef.justView) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.dicShow = true;
      this.dicType = type;
    },
    dicSelectOpen(type, keyWords) {
      if (type == this.dicType) {
        if (this.dicKeyWords == keyWords && this.dicShow) {
          return true;
        }
        return false;
      }
    },
    back() {
      this.backPrev(
        {
          paramKey: 'refresh',
          param: true,
        },
        Number(this.delt)
      ); // 直接退出到列表
    },
	clickReceptionDate(){
		if (this.$refs.docComRef.justView) return;
		this.isShowDate = true;
		console.log(this.yestDate)
	},
	changeReceptionDate(key, e) {
		
		this.$refs.docComRef.setFormDataByKey(key,dateUtils.dateFormat("yyyy年MM月dd日", new Date(e.result)));
	},
  },
};
</script>

<style lang="scss" scoped>
	@import './add.scss';
</style>
